#include "stdafx.h"
#include "BigVideoData.h"

CBigVideoData::CBigVideoData()
{
}

CBigVideoData::~CBigVideoData()
{
}

BOOL CBigVideoData::AddBigVideoData(STRU_CL_CAS_GENERAL_DATA_ID& loGeneralDataID)
{
	int nType = loGeneralDataID.m_wDataType;
	RETURN_FALSE(nType<0 || nType>BIG_VIDEO_DATA_COUNT);

	CCriticalAutoLock loAutoLock(m_oCSData);
	STRU_BIG_VIDEO_DATA& loData = m_oBigVideoData[nType];
	loData.m_lRoomID = loGeneralDataID.m_lRoomID;
	loData.m_i64UserID = loGeneralDataID.m_i64UserID;
	loData.m_i64DstUserID = loGeneralDataID.m_i64DstUserID;
	loData.m_wDataType = loGeneralDataID.m_wDataType;
	loData.m_wDataLen = min(loGeneralDataID.m_wDataLen, DEF_GENERAL_DATA_LEN);
	memcpy(loData.m_szDataBuff, loGeneralDataID.m_szDataBuff, loData.m_wDataLen);
	return TRUE;
}

void CBigVideoData::GetBigVideoData(STRU_BIG_VIDEO_DATA* apData)
{
	CCriticalAutoLock loAutoLock(m_oCSData);
	for (int nIndex=0; nIndex<BIG_VIDEO_DATA_COUNT; ++nIndex)
	{
		if (m_oBigVideoData[nIndex].m_lRoomID>0)
		{
			apData[nIndex] = m_oBigVideoData[nIndex];
		}
	}
}

INT64 CBigVideoData::GetBigVideoUserID()
{
	CCriticalAutoLock loAutoLock(m_oCSData);
	return m_oBigVideoData[0].m_i64UserID;
}

void CBigVideoData::Reset(INT64 ai64UserID)
{
	CCriticalAutoLock loAutoLock(m_oCSData);
	RETURN_CHECK(ai64UserID != m_oBigVideoData[0].m_i64UserID);

	for (int nIndex=0; nIndex<BIG_VIDEO_DATA_COUNT; ++nIndex)
	{
		m_oBigVideoData[nIndex].Reset();
	}
}
